package com.minzheng.blog.service.impl;

import com.minzheng.blog.vo.MarkdownContent;
import org.springframework.stereotype.Service;

/**
 * @author wangdiyi
 * @date 2023/4/14 21:37:22
 */
@Service
public class TestImpl {
    public MarkdownContent getMarkdownContentById(Integer id) {
        // 在这里实现从数据库中获取 Markdown 内容的逻辑
        // 这里我们使用一个简单的静态数据作为示例
        String markdownContent = "@[TOC](目录)\n" +
                "\n" +
                "# 试题A：门牌制作\n" +
                "\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321192742268.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "**答案：624**\n" +
                "\n" +
                "\n" +
                "```cpp\n" +
                "#include <iostream>\n" +
                "using namespace std;\n" +
                "\n" +
                "int main(){\n" +
                "\tint ans = 0;\n" +
                "\tfor(int i=2; i<=2020; i++){\n" +
                "\t\tint t = i;\n" +
                "\t\twhile(t){\n" +
                "\t\t\tif(t%10 == 2)\n" +
                "\t\t\t\tans++;\n" +
                "\t\t\tt /= 10;\n" +
                "\t\t}\n" +
                "\t}\n" +
                "\tcout << ans<< endl;\n" +
                "\treturn 0;\n" +
                "}\n" +
                "\n" +
                "```\n" +
                "\n" +
                "# 试题B：既约分数\n" +
                "\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321192805394.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "**答案：2481215**\n" +
                "\n" +
                "```cpp\n" +
                "#include <iostream>\n" +
                "#include <algorithm>\n" +
                "using namespace std;\n" +
                "int gcd(int n,int m){\n" +
                "    if(m==0)\n" +
                "        return n;\n" +
                "    if(n<m)\n" +
                "        return gcd(n,m%n);\n" +
                "    return gcd(m,n%m);\n" +
                "}\n" +
                "int main()\n" +
                "{\n" +
                "    int ans=0;\n" +
                "    for(int i=1;i<=2020;i++){\n" +
                "        for(int j=1;j<=2020;j++){\n" +
                "            if(gcd(i,j)==1){\n" +
                "                ans++;\n" +
                "            }\n" +
                "        }\n" +
                "    }\n" +
                "    cout<<ans<<endl;\n" +
                "    return 0;\n" +
                "}\n" +
                "```\n" +
                "\n" +
                "# 试题C：蛇形填数\n" +
                "\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321192821691.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "**答案：761**\n" +
                "**思想**：仔细观察发现蛇形走向一共有4种走位，分别是右、左下、下、右上。依次对4种走向进行dfs。当x=0,y=偶数时，下一步向右走；当y=0,x=奇数时，下一步向下走；当上一个位置是向右走的（该位置记op=1）或者向左下走的(该位置op=2)都记下一个位置op=2，意思是下一步要向左下走；右上同理，只不过下一个位置op=3。依次dfs直至到达x=19,y=19截止（这里横纵坐标都从0开始）。\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321213625866.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70#pic_center)\n" +
                "\n" +
                "```cpp\n" +
                "#include <iostream>\n" +
                "#include <algorithm>\n" +
                "using namespace std;\n" +
                "int q[25][25],cnt=1;\n" +
                "void dfs(int x,int y,int op){\n" +
                "    q[x][y]=cnt++;\n" +
                "    if(x==19&&y==19)\n" +
                "        cout<<q[19][19]<<endl;\n" +
                "    if(x==20&&y==20)\n" +
                "        return ;\n" +
                "    if(x==0&&y%2==0){//向右\n" +
                "        op=1;\n" +
                "        dfs(x,y+1,op);\n" +
                "    }else if(y==0&&x%2==1){//向下\n" +
                "        op=3;\n" +
                "        dfs(x+1,y,op);\n" +
                "    }\n" +
                "    if(op==1||op==2){//左下\n" +
                "        op=2;\n" +
                "        dfs(x+1,y-1,op);\n" +
                "    }else if(op==3){//右上\n" +
                "        dfs(x-1,y+1,op);\n" +
                "    }\n" +
                "}\n" +
                "int main()\n" +
                "{\n" +
                "    dfs(0,0,1);\n" +
                "    return 0;\n" +
                "}\n" +
                "```\n" +
                "\n" +
                "# 试题D：跑步锻炼\n" +
                "\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321192835967.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "**答案：8879**\n" +
                "**思想**：先判断该年是否为闰年，再记录每个月的最多天数，依次判断该天是否为周一或初一。\n" +
                "\n" +
                "```cpp\n" +
                "#include <iostream>\n" +
                "#include <algorithm>\n" +
                "using namespace std;\n" +
                "int cnt,tip=6,ans;\n" +
                "int d[2][13]= {0,31,28,31,30,31,30,31,31,30,31,30,31,\n" +
                "               0,31,29,31,30,31,30,31,31,30,31,30,31\n" +
                "              };\n" +
                "\n" +
                "bool is_leap_year(int num)\n" +
                "{\n" +
                "    int year=num;\n" +
                "    if(year%400==0||(year%4==0&&year%100!=0))\n" +
                "        return true;\n" +
                "    return false;\n" +
                "}\n" +
                "\n" +
                "int count_day(int num,int tip)\n" +
                "{\n" +
                "    for(int num=2000;num<=2020;num++){\n" +
                "        int year=num;\n" +
                "        int month=1;\n" +
                "        int day=1;\n" +
                "        int s_month=12;\n" +
                "        if(num==2020){\n" +
                "            s_month=10;\n" +
                "        }\n" +
                "        for(int j=month; j<=s_month; j++)\n" +
                "        {\n" +
                "            int maxday=d[0][j];\n" +
                "            if(is_leap_year(num))\n" +
                "            {\n" +
                "                maxday=d[1][j];\n" +
                "            }\n" +
                "            for(int z=day; z<=maxday; z++,tip++)\n" +
                "            {\n" +
                "                cnt++;\n" +
                "                if(tip>7)\n" +
                "                    tip=1;\n" +
                "                if(z==1||tip==1)\n" +
                "                    cnt++;\n" +
                "                if(num==2020&&j==10&&z==1)\n" +
                "                    return cnt;\n" +
                "            }\n" +
                "        }\n" +
                "    }\n" +
                "}\n" +
                "int main()\n" +
                "{\n" +
                "    cout<<count_day(2020,6)<<endl;\n" +
                "    return 0;\n" +
                "}\n" +
                "```\n" +
                "\n" +
                "# 试题F：成绩统计\n" +
                "\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321192937234.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321192957459.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321193014988.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "**思想**：注意输出，是%0.0lf，不是%0.01f哦。\n" +
                "\n" +
                "```cpp\n" +
                "#include <iostream>\n" +
                "#include <cstdio>\n" +
                "#include <algorithm>\n" +
                "using namespace std;\n" +
                "int cnt,tip=6,ans;\n" +
                "\n" +
                "int main()\n" +
                "{\n" +
                "    double  n,num,c1=0,c2=0;\n" +
                "    cin>>n;\n" +
                "    for(int i=0;i<n;i++){\n" +
                "        cin>>num;\n" +
                "        if(num>=60)\n" +
                "            c1++;\n" +
                "        if(num>=85)\n" +
                "            c2++;\n" +
                "    }\n" +
                "    printf(\"%.0lf%%\\n%.0lf%%\\n\",100*c1/n,100*c2/n);\n" +
                "    return 0;\n" +
                "}\n" +
                "```\n" +
                "\n" +
                "# 试题G：回文日期\n" +
                "\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/2021032119305254.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321193105772.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321193135518.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "**思想**：无脑暴力必然爆表。看到题目中范围是8位数，我们可以直接从年份入手，依次判断月和日是否合法，以及是否满足条件即可。其中judge函数判断是第一个回文日期，judge1函数判断的是第一个ABABBABA日期。**这个代码只拿了90分，还有一个测试点没过，目前还没找出问题。**\n" +
                "\n" +
                "```cpp\n" +
                "#include <iostream>\n" +
                "#include <cstdio>\n" +
                "#include <algorithm>\n" +
                "using namespace std;\n" +
                "int flag,flag1;\n" +
                "int d[2][13]= {0,31,28,31,30,31,30,31,31,30,31,30,31,\n" +
                "               0,31,29,31,30,31,30,31,31,30,31,30,31\n" +
                "              };\n" +
                "bool is_leap_year(int num)\n" +
                "{\n" +
                "    if(num%400==0||(num%4==0&&num%100!=0))\n" +
                "        return true;\n" +
                "    return false;\n" +
                "}\n" +
                "bool judge(int num)\n" +
                "{\n" +
                "    int r_month=num/100;\n" +
                "    int r_day=num%100;\n" +
                "    int month=(num%10)*10+(num/10)%10;\n" +
                "    int day=((num/100)%10)*10+num/1000;\n" +
                "    if(month<=12&&month>0)\n" +
                "    {\n" +
                "        int maxday=d[0][month];\n" +
                "        if(is_leap_year(num))\n" +
                "            maxday=d[1][month];\n" +
                "        if(day<=maxday){\n" +
                "            flag=1;\n" +
                "            printf(\"%d%02d%02d\\n\",num,month,day);\n" +
                "                return true;\n" +
                "        }\n" +
                "    }\n" +
                "    return false;\n" +
                "}\n" +
                "\n" +
                "bool judge1(int num)\n" +
                "{\n" +
                "    int r_month=num/100;\n" +
                "    int r_day=num%100;\n" +
                "    int month=(num%10)*10+(num/10)%10;\n" +
                "    int day=((num/100)%10)*10+num/1000;\n" +
                "     if(r_month!=r_day)\n" +
                "        return false;\n" +
                "    if(month<=12&&month>=0)\n" +
                "    {\n" +
                "        int maxday=d[0][month];\n" +
                "        if(is_leap_year(num))\n" +
                "            maxday=d[1][month];\n" +
                "        if(day<=maxday){\n" +
                "            flag1=1;\n" +
                "            printf(\"%d%02d%02d\\n\",num,month,day);//注意输出要符合日期规范，20200202对，202022错。\n" +
                "                return true;\n" +
                "        }\n" +
                "    }\n" +
                "    return false;\n" +
                "}\n" +
                "int main()\n" +
                "{\n" +
                "    int num,year;\n" +
                "    cin>>num;\n" +
                "    year=num/10000;\n" +
                "    for(int i=year+1;i<=9999;i++){\n" +
                "        if(!flag){\n" +
                "            judge(i);\n" +
                "        }\n" +
                "        else\n" +
                "            break;\n" +
                "    }\n" +
                "    for(int i=year+1;i<=9999;i++){\n" +
                "        if(!flag1){\n" +
                "            judge1(i);\n" +
                "        }\n" +
                "        else\n" +
                "            break;\n" +
                "    }\n" +
                "    return 0;\n" +
                "}\n" +
                "```\n" +
                "\n" +
                "# 试题H：子串分值和\n" +
                "\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321193157976.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321193216874.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321193236401.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "**思想**：学长说是dp的思想，如果明白是dp就很简单，如果不知道可能就很难搞。如果按照样例那种排列组合找规则可能有点困难，我们可以换一种排列组合，更容易解决这个问题。\n" +
                "![](https://img-blog.csdnimg.cn/20210321202603873.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70#pic_center)\n" +
                "**这样是不是就更容易发现规律啦，再附一个样例**\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321202827370.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70#pic_center)\n" +
                "其实就是相同的字母中最后一个总会覆盖前面所有的字母，但计算到每个字母时都要记录当下最新的一个字母。而且我们也发现，每个字符贡献的次数就是下标值+1（下标从0开始）。\n" +
                "\n" +
                "```cpp\n" +
                "#include <iostream>\n" +
                "#include <cstdio>\n" +
                "#include <algorithm>\n" +
                "#include <cstring>\n" +
                "using namespace std;\n" +
                "char d[100005];\n" +
                "int p[27];\n" +
                "long long cnt;\n" +
                "\n" +
                "int main()\n" +
                "{\n" +
                "\n" +
                "    cin>>d;\n" +
                "    int len=strlen(d);\n" +
                "    for(int i=0;i<len;i++){\n" +
                "        p[d[i]-'a']=i+1;\n" +
                "        for(int j=0;j<26;j++){\n" +
                "            cnt+=p[j];\n" +
                "        }\n" +
                "    }\n" +
                "    cout<<cnt<<endl;\n" +
                "    return 0;\n" +
                "}\n" +
                "```\n" +
                "\n" +
                "# 试题I：平面切分\n" +
                "\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/20210321193308791.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/2021032119332744.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70)\n" +
                "**思想**：这题在学长讲完之后我以为我懂了（其实就是我以为而已），自己上手敲代码的时候发现计算最终值并不是直接地等于所有交点数+有效直线数（不含重合直线）+1，而是每一条直线一条一条插进去模拟计算，插入这条直线时计算该条直线与前面所有直线的交点个数，直到最后一条直线插入结束（之所以一条一条模拟而不是上来就找全部的交点是因为这中间会有重复的交点，直接计算会漏掉许多有贡献的交点，而一条一条插入不会漏掉并且会很容易发现规律（每增加一个结点就会贡献一个分割平面））。用flag1[x][y]记录当下交点，避免重复。**注意flag1是用map存的，x,y均为浮点型。**\n" +
                "![在这里插入图片描述](https://img-blog.csdnimg.cn/2021032121051723.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmdkaXlp,size_16,color_FFFFFF,t_70#pic_center)\n" +
                "**这样举例是不是就容易找到规律啦，自己可以动手多画画，也可以按照我之前错误的想法一次性把所有的直线都画出来再计算交点，这时候就会发现出现问题了，因为有的点重复后并没有计算它之前的贡献值。两种思想一对比就能加深自己的模拟思想了，所以有时候你以为懂了其实是没懂哈哈。**\n" +
                "\n" +
                "```cpp\n" +
                "#include <iostream>\n" +
                "#include <cstdio>\n" +
                "#include <algorithm>\n" +
                "#include <cstring>\n" +
                "#include <map>\n" +
                "using namespace std;\n" +
                "long ans;\n" +
                "map<int, map<int, int> > flag;\n" +
                "int q[1007][3];\n" +
                "int main()\n" +
                "{\n" +
                "    int n,x,y,in=0;\n" +
                "    cin>>n;\n" +
                "    for(int i=0;i<n;i++){\n" +
                "        scanf(\"%d %d\", &x, &y);\n" +
                "        if(!flag[x][y]){\n" +
                "            flag[x][y]=1;\n" +
                "            q[in][0]=x;\n" +
                "            q[in][1]=y;\n" +
                "            in++;\n" +
                "        }\n" +
                "    }\n" +
                "    map<double, map<double,double> > flag1;\n" +
                "    for(int in1=0;in1<in;in1++){\n" +
                "        flag1.clear();\n" +
                "        for(int in2=0;in2<in1;in2++){\n" +
                "            if(q[in1][0]==q[in2][0])\n" +
                "                continue;\n" +
                "            double x=(q[in2][1]-q[in1][1])/(double)(q[in1][0]-q[in2][0]);\n" +
                "            double y=q[in1][0]*x+q[in1][1];\n" +
                "            if(!flag1[x][y]){\n" +
                "                flag1[x][y]=1;\n" +
                "                ans++;\n" +
                "            }\n" +
                "        }\n" +
                "    }\n" +
                "    cout << 1 + in + ans;\n" +
                "    return 0;\n" +
                "}\n" +
                "```";

        MarkdownContent new_markdown=new MarkdownContent();
        new_markdown.setId(id);
        new_markdown.setContent(markdownContent);
//        System.out.println(new_markdown.getId()+"  "+new_markdown.getContent());
        return new_markdown;
    }
}